﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WinFrom2
{
    public partial class Add : Form
    {
        public Add()
        {
            InitializeComponent();
        }

        private void button3_Click(object sender, EventArgs e)
        {
            var res = MessageBox.Show("是否保存？", "提示", MessageBoxButtons.OKCancel);
            if (res.Equals(DialogResult.OK))
            {
                string sql = string.Format("insert into Articles (Title ,Author) values ('{0}',{1})", textBox1 .Text ,textBox2 .Text );
                var rp = Dbhelper .AddOrEdiOrdeletetSave (sql);
                if (rp > 0)
                {
                    MessageBox.Show("添加成功", "提示", MessageBoxButtons.OK);
                    this.DialogResult = DialogResult.OK;
                    this.Close();
                }
                else
                {
                    MessageBox.Show("保存失败", "提示", MessageBoxButtons.OK);
                }

            }
            else
            {
                var res2 = MessageBox.Show("取消成功", "提示", MessageBoxButtons.OK);
            }
        }
    }
  }

